package top.javahai.subtlechat.base.dao.Impl;

import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
import top.javahai.subtlechat.api.pojo.User;
import top.javahai.subtlechat.base.dao.ChatUserDao;

import javax.annotation.Resource;


/**
 * @author qiangfanghao
 * @date
 */
@Repository("chatUserDao")
public class ChatUserDaoImpl implements ChatUserDao {

    @Resource(name = "mongoMajorTemplate")
    private MongoTemplate mongoTemplate;


    @Override
    public User loadUserByUsername(String username) {
        Query query = Query.query(Criteria.where("username").is(username));
        return this.mongoTemplate.findOne(query, User.class);
    }
}
